/********* totop.m Cordova Plugin Implementation *******/

#import <Cordova/CDV.h>

@interface totop : CDVPlugin {
  // Member variables go here.
}
@property (nonatomic,strong) CDVInvokedUrlCommand* command;
- (void)coolMethod:(CDVInvokedUrlCommand*)command;
@end

@implementation totop

- (void)coolMethod:(CDVInvokedUrlCommand*)command
{
    self.command = command;
    CDVPluginResult* pluginResult = nil;
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
    [pluginResult setKeepCallbackAsBool:YES];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(topTop:) name:@"TOTOP" object:nil];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)topTop:(NSNotification *)n{
    CDVPluginResult* pluginResult = nil;
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"ToTop"];
    [pluginResult setKeepCallbackAsBool:YES];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:self.command.callbackId];
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
